<template>
	<view class="content">
		<form @submit="formSubmit">
			<view class="logo">
				<image :src="userInfo.img" @tap="image"></image>
			</view> 
			<view class="uni-form-item uni-column">
				用户手机号
				<input type="tel" class="uni-input" name="mobile" v-model="userInfo.userId" placeholder="请输入用户手机号" />
			</view>
			<view class="uni-form-item uni-column">
				积分
				<input type="text" class="uni-input" name="introduce" v-model="userInfo.introduce" placeholder="请输入增加积分" />
			</view>
			<button class="tui-btn" formType="submit">保存</button>
		</form>
	</view>
</template>

<script>
	const form = require("../../components/utils/formValidation.js")
	import yonghuTags from '@/components/xinliziliao/yonghuTags'
	import uploadImage from '@/js_sdk/yushijie-ossutil/ossutil/uploadFile.js';
	export default {
		components: {
			yonghuTags
		},
		data() {
			return {
				yonghuBiaoQian : [],
				userInfo: {
					user: '',
					userId: '',
					oldPassWord: '',
					passWord: '',
					introduce : '',
					userSig: '1',
					img: 'https://jihe2.oss-cn-beijing.aliyuncs.com/xinli/login/logo.png',
					xiugairen : ''
				},
				codes: [],
				behavior: [],
				fear: [],
				condition: [],
				emotion: [],
			}
		},
		onLoad() {
			// #ifndef H5
			uni.showShareMenu({
				showShareItems : ['qq', 'qzone', 'wechatFriends', 'wechatMoment']	
			});
			// #endif
			this.init();
		},
		methods: {
			init(){
				let user = this.$xinli.user.getUserInfo();
				const that = this;
				if (user) {
					this.userInfo = user
					this.userInfo.introduce = 1;
					this.userInfo.xiugairen = this.userInfo.userId;
				}
			},
			formSubmit: function(e) {
				//表单规则
				let rules = [{
					name: "mobile",
					rule: ["required", "isMobile"],
					msg: ["请输入手机号", "请输入正确的手机号"]
				}, {
					name: "introduce",
					rule: ["required"], //可使用区间，此处主要测试功能
					msg: ["请输入积分"]
				}];
				//进行表单检查
				let formData = e.detail.value;
				let checkRes = form.validation(formData, rules);
				if (!checkRes) {
					const data = this.userInfo;
					uni.reLaunch({
						url: `my`
					})
					this.$apiW.addJiFen(data);
				} else {
					uni.showToast({
						title: checkRes,
						icon: "none"
					});
				}
			},
			gotoLogin: function() {
				uni.navigateTo({
					url: 'login'
				})
			},
			radioChange: function(evt) {
				for (let i = 0; i < this.items.length; i++) {
					if (this.items[i].value === evt.target.value) {
						this.current = this.items[i].value;
						//break;
					}
				}
				console.log(this.current);
			},
		},
		computed: {
		}
	}
</script>

<style lang="scss" scoped>
	@import '../../static/style/thorui.css';
	$color-primary: #b49950;

	.tui-btn {
		margin-top: 30upx;
		background-color: #df5451;
		color: #fff;
	}

	.content {
		padding: 60upx;
	}

	.logo {
		text-align: center;
		border-radius: 50%;
		overflow: hidden;
		image {
			height: 200upx;
			width: 200upx;
			margin: 0 0 40upx;
			border-radius: 50%;
		}
	}

	.uni-form-item {
		margin-bottom: 40upx;
		padding: 0;
		border-bottom: 1px solid #e3e3e3;

		.uni-input {
			font-size: 30upx;
			padding: 7px 0;
		}
	}

	.column-with-btn {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;

		button {
			font-size: 24upx;
			margin: 0;
			width: 180upx;
			text-align: center;

			&:after {
				border: none
			}

			&.active {
				background-color: $color-primary;
				color: $uni-text-color-inverse;
			}
		}
	}

	.img-captcha {
		width: 150upx;
		height: 60upx;
	}

	button[type="primary"] {
		background-color: $color-primary;
		border-radius: 0;
		font-size: 34upx;
		margin-top: 60upx;
	}

	.links {
		text-align: center;
		margin-top: 40upx;
		font-size: 26upx;
		color: #999;

		view {
			display: inline-block;
			vertical-align: top;
			margin: 0 10upx;
		}

		.link-highlight {
			color: $color-primary
		}
	}

	.radio-change {
		margin-right: 50upx;
	}
</style>
